package com.tjdx.projectsubmission.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tjdx.projectsubmission.dto.FillReportListDto;
import com.tjdx.projectsubmission.dto.FillReportQueryDto;
import com.tjdx.projectsubmission.dto.FillReportSaveDto;
import com.tjdx.projectsubmission.db.entity.FillReport;
import com.tjdx.projectsubmission.service.FillReportService;
import com.tjdx.projectsubmission.vo.R;
import com.tjdx.projectsubmission.vo.fill.FileReportListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;


@RestController
@RequestMapping("/report")
public class FillReportController {


    @Autowired
    private FillReportService fillReportService;


    /**
     * 获取此用户当前是否存在填报
     */
    @PostMapping("/getOneReport")
    public R getOneReport(@RequestBody FillReportQueryDto fillReportQueryDto) {
        FileReportListVo fillReport = fillReportService.getOneReport(fillReportQueryDto);
        return R.ok().data("data", fillReport);
    }


    /**
     * 保存工程填报-全部保存提交
     */
    @PostMapping("/saveReport")
    public R saveReport(@RequestBody FillReportSaveDto fillReportSaveDto) {
        return fillReportService.saveReport(fillReportSaveDto);
    }


    /**
     * 保存工程填报-审核  提交
     */
    @GetMapping("/auditing")
    public R auditing(Long id) {
        return fillReportService.auditing(id);
    }



    /**
     * 获取管理列表页面
     */
    @PostMapping("/getAllReport")
    public R getAllReport(@RequestBody FillReportListDto fillReportListDto) {
        IPage<FileReportListVo> page = fillReportService.getAllReport(fillReportListDto);
        return R.ok().data("data", page);
    }


    /**
     * 提交梧桐链
     */
    @GetMapping("/reportSubmit")
    public R reportSubmit(Long id,Long riskLevel) {
        return fillReportService.reportSubmit(id,riskLevel);
    }


    /**
     * 区块信息列表
     */
    @GetMapping("/list")
    public R list() {
        return R.ok().data("data", fillReportService.list());
    }


}
